def resolution1():
    N = int(input())
    for i in range(N):
        gender, height = input().split(' ')
        gender = str(gender)
        height = float(height)
        if gender == 'M':
            print("%.2f" % (height / 1.09))
        else:
            print("%.2f" % (height*1.09))


if __name__ == '__main__':
    resolution1()